<template>
    <div class="demo3">
        <h2>姓名:{{name}}</h2>
        <h2>年龄:{{age}}</h2>
        <button @click="sendStudentName">把学生名给School组件</button>
    </div>
</template>

<script>
    import pubsub from 'pubsub-js';
    export default {
        name:'Student',
        data() {
            return {
                name:'潘定道',
                age:22
            }
        },
        methods:{
            sendStudentName(){
                pubsub.publish('hello',666);//发布消息
            }
        }
    }
</script>

<style scoped>
    .demo3{
        background-color: skyblue;
    }
</style>